﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DTO;
using System.Data;
using System.Data.SqlClient;
namespace DAL
{
    public class PhuHuynh_DAL
    {
        private DataProvider _provider = new DataProvider();
	
		    public PhuHuynh_DAL()
		    {
			    _provider.connect();
		    }
            public void ThemPhuHuynh(PhuHuynh_DTO ph)
            {

                //List<SqlParameter> paramters = new List<SqlParameter>();
                //paramters.Add(new SqlParameter("@MaHS", info.MaHS));
                string insertCommand = @"INSERT INTO PHUHUYNH (TenPH, Nghenghiep, Diachi, CMND, SDT) VALUES('" +
                    ph.TenPH + "', '" +
                    ph.Nghenghiep + "', '" + ph.DiaChi + "', '" + ph.CMND + "', '" + ph.SDT + "')";

                _provider.executeNonQuery(insertCommand);
            }

            public List<PhuHuynh_DTO> DS_PhuHuynh()
            {

                SqlDataReader reader = (SqlDataReader)_provider.executeQuery("DS_PhuHuynh");

                List<PhuHuynh_DTO> List_PhuHuynh = new List<PhuHuynh_DTO>();

                while (reader.Read())
                {
                    PhuHuynh_DTO ph = new PhuHuynh_DTO();
                    ph.MaPH = int.Parse(reader["MaPH"].ToString());
                    ph.Nghenghiep = reader["Nghenghiep"].ToString();
                    ph.DiaChi = reader["Diachi"].ToString();
                    ph.SDT = reader["SDT"].ToString();
                    ph.CMND = reader["CMND"].ToString();
                    

                    List_PhuHuynh.Add(ph);
                }

                reader.Close();
                return List_PhuHuynh;
            }

    }
}
